package com.iepacj.redis;

import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedisPool;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by iEpac on 16/5/4.
 */
public class RedisConfiguration {

    public void getConf() {

        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxIdle(100);
        poolConfig.setMaxTotal(2000);
        poolConfig.setMaxWaitMillis(300000);
        poolConfig.setMinIdle(60000);

        List<JedisShardInfo> shards = new ArrayList<>();

        JedisShardInfo shard1 = new JedisShardInfo("localhost", 6379, 3000, "redis-master");
        JedisShardInfo shard2 = new JedisShardInfo("localhost", 6380, 3000, "redis-slave1");
        JedisShardInfo shard3 = new JedisShardInfo("localhost", 6381, 3000, "redis-slave2");

        shards.add(shard1);
        shards.add(shard2);
        shards.add(shard3);

        ShardedJedisPool shardedJedisPool = new ShardedJedisPool(poolConfig, shards);


    }


}
